import { Commit } from "vuex";
import { LayoutState } from "../interface";
import _ from "lodash"

// 初始化 state
const initState: LayoutState = {
    mainLoading: {
        open: false
    }
}

// 仓库数据
const state: LayoutState = _.cloneDeep(initState)

const mutations = {
    // 开启 main区域 加载效果
    OPEN_Main_LOADING(state: LayoutState, value: boolean) {
        state.mainLoading = {
            ...initState.mainLoading,
            open: value
        }
    },
    // 关闭 main区域 加载效果
    CLOSE_Main_LOADING(state: LayoutState) {
        state.mainLoading = {
            ...initState.mainLoading
        }
    }
};

const actions = {
    openMainLoading({ commit }: { commit: Commit }) {
        commit("OPEN_Main_LOADING", true)
    },
    closeMainLoading({ commit }: { commit: Commit }) {
        commit("CLOSE_Main_LOADING")
    }
};

// getters
const getters = {

};

export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
};